/**
 *
 */

import React, { useRef } from "react";
import {FCForm} from "@components";
import { message } from "antd";
import { getFields } from "../config/config";
 import styles from "../style/search.module.css";

const Search = React.memo(({ submit }) => {
    const formRef = useRef("realTimeRiskSearch")

    const onFinish = (values) => {
        console.log(values);
        let empty = Object.values(values).some(item => item)
        if (!empty) {
            message.info('查询条件不能为空')
            return
        }
        submit(values)
    };

    const from = {
        name: "searchForm",
        formRef,
        fields: getFields(),
        onFinish,
        submitButton: {
          show: true,
          icon: "SearchOutlined",
          label: "查询",
        },
        layoutProps: {
          layout: "grid",
          gridConfig: { colCount: 3 },
        },
        isButtonLineFeed: false,
      };

      return(
        <div className={styles.search}>
            <FCForm 
            {...from} />
        </div>
      )
});
export default Search;